/**
 * 学科服务
 */
angular
.module('myApp')
.factory('subjectManager', function($http, $q) {
  return {
    /**
     * 获取当前用户学科信息
     */
    getSubjects: function() {
      var def = $q.defer();

      $http.get('/lesson/subject')
        .then(function(response) {
          (response.data.code === 200)
            ? def.resolve(response.data.data)
            : def.reject(response.data.data);
        }, function(response) {
          def.reject({msg: response.status+': '+response.statusText});
        });

      return def.promise;
    }
  }
});
